home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / u_man / cat1 / perlapio.z / perlapio
Encoding:
Text File  |  2002-10-03  |  15.4 KB  |  397 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))                                                        PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      perlapio - perl's IO abstraction interface.
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          PerlIO *PerlIO_stdin(void);
  13.          PerlIO *PerlIO_stdout(void);
  14.          PerlIO *PerlIO_stderr(void);
  15.  
  16.          PerlIO *PerlIO_open(const char *,const char *);
  17.          int     PerlIO_close(PerlIO *);
  18.  
  19.          int     PerlIO_stdoutf(const char *,...)
  20.          int     PerlIO_puts(PerlIO *,const char *);
  21.          int     PerlIO_putc(PerlIO *,int);
  22.          int     PerlIO_write(PerlIO *,const void *,size_t);
  23.          int     PerlIO_printf(PerlIO *, const char *,...);
  24.          int     PerlIO_vprintf(PerlIO *, const char *, va_list);
  25.          int     PerlIO_flush(PerlIO *);
  26.  
  27.          int     PerlIO_eof(PerlIO *);
  28.          int     PerlIO_error(PerlIO *);
  29.          void    PerlIO_clearerr(PerlIO *);
  30.  
  31.          int     PerlIO_getc(PerlIO *);
  32.          int     PerlIO_ungetc(PerlIO *,int);
  33.          int     PerlIO_read(PerlIO *,void *,size_t);
  34.  
  35.          int     PerlIO_fileno(PerlIO *);
  36.          PerlIO *PerlIO_fdopen(int, const char *);
  37.          PerlIO *PerlIO_importFILE(FILE *, int flags);
  38.          FILE   *PerlIO_exportFILE(PerlIO *, int flags);
  39.          FILE   *PerlIO_findFILE(PerlIO *);
  40.          void    PerlIO_releaseFILE(PerlIO *,FILE *);
  41.  
  42.          void    PerlIO_setlinebuf(PerlIO *);
  43.  
  44.          long    PerlIO_tell(PerlIO *);
  45.          int     PerlIO_seek(PerlIO *,off_t,int);
  46.          int     PerlIO_getpos(PerlIO *,Fpos_t *)
  47.          int     PerlIO_setpos(PerlIO *,Fpos_t *)
  48.          void    PerlIO_rewind(PerlIO *);
  49.  
  50.          int     PerlIO_has_base(PerlIO *);
  51.          int     PerlIO_has_cntptr(PerlIO *);
  52.          int     PerlIO_fast_gets(PerlIO *);
  53.          int     PerlIO_canset_cnt(PerlIO *);
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))                                                        PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))
  71.  
  72.  
  73.  
  74.          char   *PerlIO_get_ptr(PerlIO *);
  75.          int     PerlIO_get_cnt(PerlIO *);
  76.          void    PerlIO_set_cnt(PerlIO *,int);
  77.          void    PerlIO_set_ptrcnt(PerlIO *,char *,int);
  78.          char   *PerlIO_get_base(PerlIO *);
  79.          int     PerlIO_get_bufsiz(PerlIO *);
  80.  
  81.  
  82. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  83.      Perl's source code should use the above functions instead of those
  84.      defined in ANSI C's _s_t_d_i_o._h.  The perl headers will #define them to the
  85.      I/O mechanism selected at Configure time.
  86.  
  87.      The functions are modeled on those in _s_t_d_i_o._h, but parameter order has
  88.      been "tidied up a little".
  89.  
  90.      PPPPeeeerrrrllllIIIIOOOO ****
  91.          This takes the place of FILE *. Like FILE * it should be treated as
  92.          opaque (it is probably safe to assume it is a pointer to something).
  93.  
  94.      PPPPeeeerrrrllllIIIIOOOO____ssssttttddddiiiinnnn(((()))), PPPPeeeerrrrllllIIIIOOOO____ssssttttddddoooouuuutttt(((()))), PPPPeeeerrrrllllIIIIOOOO____ssssttttddddeeeerrrrrrrr(((())))
  95.          Use these rather than stdin, stdout, stderr. They are written to look
  96.          like "function calls" rather than variables because this makes it
  97.          easier to _m_a_k_e _t_h_e_m function calls if platform cannot export data to
  98.          loaded modules, or if (say) different "threads" might have different
  99.          values.
  100.  
  101.      PPPPeeeerrrrllllIIIIOOOO____ooooppppeeeennnn((((ppppaaaatttthhhh,,,, mmmmooooddddeeee)))), PPPPeeeerrrrllllIIIIOOOO____ffffddddooooppppeeeennnn((((ffffdddd,,,,mmmmooooddddeeee))))
  102.          These correspond to _f_o_p_e_n()/_f_d_o_p_e_n() arguments are the same.
  103.  
  104.      PPPPeeeerrrrllllIIIIOOOO____pppprrrriiiinnnnttttffff((((ffff,,,,ffffmmmmtttt,,,,............)))), PPPPeeeerrrrllllIIIIOOOO____vvvvpppprrrriiiinnnnttttffff((((ffff,,,,ffffmmmmtttt,,,,aaaa))))
  105.          These are _f_p_r_i_n_t_f()/_v_f_p_r_i_n_t_f() equivalents.
  106.  
  107.      PPPPeeeerrrrllllIIIIOOOO____ssssttttddddoooouuuuttttffff((((ffffmmmmtttt,,,,............))))
  108.          This is _p_r_i_n_t_f() equivalent. printf is #defined to this function, so
  109.          it is (currently) legal to use printf(fmt,...) in perl sources.
  110.  
  111.      PPPPeeeerrrrllllIIIIOOOO____rrrreeeeaaaadddd((((ffff,,,,bbbbuuuuffff,,,,ccccoooouuuunnnntttt)))), PPPPeeeerrrrllllIIIIOOOO____wwwwrrrriiiitttteeee((((ffff,,,,bbbbuuuuffff,,,,ccccoooouuuunnnntttt))))
  112.          These correspond to _f_r_e_a_d() and _f_w_r_i_t_e(). Note that arguments are
  113.          different, there is only one "count" and order has "file" first.
  114.  
  115.      PPPPeeeerrrrllllIIIIOOOO____cccclllloooosssseeee((((ffff))))
  116.  
  117.      PPPPeeeerrrrllllIIIIOOOO____ppppuuuuttttssss((((ffff,,,,ssss)))), PPPPeeeerrrrllllIIIIOOOO____ppppuuuuttttcccc((((ffff,,,,cccc))))
  118.          These correspond to _f_p_u_t_s() and _f_p_u_t_c().  Note that arguments have
  119.          been revised to have "file" first.
  120.  
  121.      PPPPeeeerrrrllllIIIIOOOO____uuuunnnnggggeeeettttcccc((((ffff,,,,cccc))))
  122.          This corresponds to _u_n_g_e_t_c().  Note that arguments have been revised
  123.          to have "file" first.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))                                                        PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))
  137.  
  138.  
  139.  
  140.      PPPPeeeerrrrllllIIIIOOOO____ggggeeeettttcccc((((ffff))))
  141.          This corresponds to _g_e_t_c().
  142.  
  143.      PPPPeeeerrrrllllIIIIOOOO____eeeeooooffff((((ffff))))
  144.          This corresponds to _f_e_o_f().
  145.  
  146.      PPPPeeeerrrrllllIIIIOOOO____eeeerrrrrrrroooorrrr((((ffff))))
  147.          This corresponds to _f_e_r_r_o_r().
  148.  
  149.      PPPPeeeerrrrllllIIIIOOOO____ffffiiiilllleeeennnnoooo((((ffff))))
  150.          This corresponds to _f_i_l_e_n_o(), note that on some platforms, the
  151.          meaning of "fileno" may not match Unix.
  152.  
  153.      PPPPeeeerrrrllllIIIIOOOO____cccclllleeeeaaaarrrreeeerrrrrrrr((((ffff))))
  154.          This corresponds to _c_l_e_a_r_e_r_r(), i.e., clears 'eof' and 'error' flags
  155.          for the "stream".
  156.  
  157.      PPPPeeeerrrrllllIIIIOOOO____fffflllluuuusssshhhh((((ffff))))
  158.          This corresponds to _f_f_l_u_s_h().
  159.  
  160.      PPPPeeeerrrrllllIIIIOOOO____tttteeeellllllll((((ffff))))
  161.          This corresponds to _f_t_e_l_l().
  162.  
  163.      PPPPeeeerrrrllllIIIIOOOO____sssseeeeeeeekkkk((((ffff,,,,oooo,,,,wwww))))
  164.          This corresponds to _f_s_e_e_k().
  165.  
  166.      PPPPeeeerrrrllllIIIIOOOO____ggggeeeettttppppoooossss((((ffff,,,,pppp)))), PPPPeeeerrrrllllIIIIOOOO____sssseeeettttppppoooossss((((ffff,,,,pppp))))
  167.          These correspond to _f_g_e_t_p_o_s() and _f_s_e_t_p_o_s(). If platform does not
  168.          have the stdio calls then they are implemented in terms of
  169.          _P_e_r_l_I_O__t_e_l_l() and _P_e_r_l_I_O__s_e_e_k().
  170.  
  171.      PPPPeeeerrrrllllIIIIOOOO____rrrreeeewwwwiiiinnnndddd((((ffff))))
  172.          This corresponds to _r_e_w_i_n_d(). Note may be redefined in terms of
  173.          _P_e_r_l_I_O__s_e_e_k() at some point.
  174.  
  175.      PPPPeeeerrrrllllIIIIOOOO____ttttmmmmppppffffiiiilllleeee(((())))
  176.          This corresponds to _t_m_p_f_i_l_e(), i.e., returns an anonymous PerlIO
  177.          which will automatically be deleted when closed.
  178.  
  179.      CCCCoooo----eeeexxxxiiiisssstttteeeennnncccceeee wwwwiiiitttthhhh ssssttttddddiiiioooo
  180.  
  181.      There is outline support for co-existence of PerlIO with stdio.
  182.      Obviously if PerlIO is implemented in terms of stdio there is no problem.
  183.      However if perlio is implemented on top of (say) sfio then mechanisms
  184.      must exist to create a FILE * which can be passed to library code which
  185.      is going to use stdio calls.
  186.  
  187.      PPPPeeeerrrrllllIIIIOOOO____iiiimmmmppppoooorrrrttttFFFFIIIILLLLEEEE((((ffff,,,,ffffllllaaaaggggssss))))
  188.          Used to get a PerlIO * from a FILE *.  May need additional arguments,
  189.          interface under review.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))                                                        PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))
  203.  
  204.  
  205.  
  206.      PPPPeeeerrrrllllIIIIOOOO____eeeexxxxppppoooorrrrttttFFFFIIIILLLLEEEE((((ffff,,,,ffffllllaaaaggggssss))))
  207.          Given an PerlIO * return a 'native' FILE * suitable for passing to
  208.          code expecting to be compiled and linked with ANSI C _s_t_d_i_o._h.
  209.  
  210.          The fact that such a FILE * has been 'exported' is recorded, and may
  211.          affect future PerlIO operations on the original PerlIO *.
  212.  
  213.      PPPPeeeerrrrllllIIIIOOOO____ffffiiiinnnnddddFFFFIIIILLLLEEEE((((ffff))))
  214.          Returns previously 'exported' FILE * (if any).  Place holder until
  215.          interface is fully defined.
  216.  
  217.      PPPPeeeerrrrllllIIIIOOOO____rrrreeeelllleeeeaaaasssseeeeFFFFIIIILLLLEEEE((((pppp,,,,ffff))))
  218.          Calling PerlIO_releaseFILE informs PerlIO that all use of FILE * is
  219.          complete. It is removed from list of 'exported' FILE *s, and
  220.          associated PerlIO * should revert to original behaviour.
  221.  
  222.      PPPPeeeerrrrllllIIIIOOOO____sssseeeettttlllliiiinnnneeeebbbbuuuuffff((((ffff))))
  223.          This corresponds to _s_e_t_l_i_n_e_b_u_f(). Use is deprecated pending further
  224.          discussion. (Perl core uses it _o_n_l_y when "dumping"; it has nothing to
  225.          do with $| auto-flush.)
  226.  
  227.      In addition to user API above there is an "implementation" interface
  228.      which allows perl to get at internals of PerlIO.  The following calls
  229.      correspond to the various FILE_xxx macros determined by Configure. This
  230.      section is really of interest to only those concerned with detailed
  231.      perl-core behaviour or implementing a PerlIO mapping.
  232.  
  233.      PPPPeeeerrrrllllIIIIOOOO____hhhhaaaassss____ccccnnnnttttppppttttrrrr((((ffff))))
  234.          Implementation can return pointer to current position in the "buffer"
  235.          and a count of bytes available in the buffer.
  236.  
  237.      PPPPeeeerrrrllllIIIIOOOO____ggggeeeetttt____ppppttttrrrr((((ffff))))
  238.          Return pointer to next readable byte in buffer.
  239.  
  240.      PPPPeeeerrrrllllIIIIOOOO____ggggeeeetttt____ccccnnnntttt((((ffff))))
  241.          Return count of readable bytes in the buffer.
  242.  
  243.      PPPPeeeerrrrllllIIIIOOOO____ccccaaaannnnsssseeeetttt____ccccnnnntttt((((ffff))))
  244.          Implementation can adjust its idea of number of bytes in the buffer.
  245.  
  246.      PPPPeeeerrrrllllIIIIOOOO____ffffaaaasssstttt____ggggeeeettttssss((((ffff))))
  247.          Implementation has all the interfaces required to allow perl's fast
  248.          code to handle <FILE> mechanism.
  249.  
  250.            PerlIO_fast_gets(f) = PerlIO_has_cntptr(f) && \
  251.                                  PerlIO_canset_cnt(f) && \
  252.                                  `Can set pointer into buffer'
  253.  
  254.  
  255.      PPPPeeeerrrrllllIIIIOOOO____sssseeeetttt____ppppttttrrrrccccnnnntttt((((ffff,,,,pppp,,,,cccc))))
  256.          Set pointer into buffer, and a count of bytes still in the buffer.
  257.          Should be used only to set pointer to within range implied by
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))                                                        PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))
  269.  
  270.  
  271.  
  272.          previous calls to PerlIO_get_ptr and PerlIO_get_cnt.
  273.  
  274.      PPPPeeeerrrrllllIIIIOOOO____sssseeeetttt____ccccnnnntttt((((ffff,,,,cccc))))
  275.          Obscure - set count of bytes in the buffer. Deprecated.  Currently
  276.          used in only doio.c to force count < -1 to -1.  Perhaps should be
  277.          PerlIO_set_empty or similar.  This call may actually do nothing if
  278.          "count" is deduced from pointer and a "limit".
  279.  
  280.      PPPPeeeerrrrllllIIIIOOOO____hhhhaaaassss____bbbbaaaasssseeee((((ffff))))
  281.          Implementation has a buffer, and can return pointer to whole buffer
  282.          and its size. Used by perl for ----TTTT / ----BBBB tests.  Other uses would be
  283.          very obscure...
  284.  
  285.      PPPPeeeerrrrllllIIIIOOOO____ggggeeeetttt____bbbbaaaasssseeee((((ffff))))
  286.          Return _s_t_a_r_t of buffer.
  287.  
  288.      PPPPeeeerrrrllllIIIIOOOO____ggggeeeetttt____bbbbuuuuffffssssiiiizzzz((((ffff))))
  289.          Return _t_o_t_a_l _s_i_z_e of buffer.
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))                                                        PPPPEEEERRRRLLLLAAAAPPPPIIIIOOOO((((1111))))
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.                                                                         PPPPaaaaggggeeee 6666
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.